import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;

public class Block implements Comparable, GameObject {
	private int x, y, width, height;
	private Image img;

	public Block(int x, int y, int width, int height, String imgPath) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		setImage(imgPath);
	}

	public Block(int x, int y, String imgPath) {
		this.x = x;
		this.y = y;
		setImage(imgPath);
	}

	public void setImage(String imgPath) {
		ImageIcon ii = new ImageIcon(this.getClass().getResource(imgPath));
		img = ii.getImage();
		if (width == 0) {
			width = img.getWidth(null);
			height = img.getHeight(null);
		}
	}

	public Image getImage() {
		return img;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

	public int compareTo(Object o) {
		Block b = (Block) o;
		if (b.y < this.y) {
			return 1;
		} else if (b.y == this.y) {
			if (b.x < this.x) {
				return 1;
			} else if (b.x > this.x) {
				return -1;
			} else {
				return 0;
			}
		} else {
			return -1;
		}

	}

	@Override
	public int getType() {
		return 1;
	}
	
	@Override
	public int getYSpeed() {
		return 0;
	}

	@Override
	public int getXSpeed() {
		return 0;
	}

	@Override
	public void specialFunction(int type) {
		// TODO Auto-generated method stub
		
	}

	public void draw(Graphics2D g2d, Game observer) {
		// TODO Auto-generated method stub
		
	}

	public int projectileCollision(int type) {
		return -1;
	}
}
